<template>
    <div class="container-content">
        <el-form
            ref="formRef"
            :model="formObject"
            label-width="160px"
            label-position="left"
            class="mt20"
            :disabled="isTask"

        >
            <el-row :gutter="20">
                <el-col :span="24">
                    <el-form-item label="保证金类型">
                        <el-radio v-model="formObject.type" :label="1" border
                            >交保证金</el-radio
                        >
                        <el-radio v-model="formObject.type" :label="2" border
                            >退保证金</el-radio
                        >
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="已审批通过的标书记录">
                        <el-input v-model="formObject.bidId"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="预计退还时间">
                        <el-date-picker
                            v-model="formObject.expectBackTime"
                            type="date"
                            placeholder="选择日期"
                            style="width: 100%"
                        >
                        </el-date-picker>
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="客户">
                        <el-input v-model="formObject.customerId"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="付款方式">
                        <el-input v-model="formObject.payTypeId"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="投标基础信息">
                        <el-input v-model="formObject.tenderId"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="添加用户">
                        <el-input v-model="formObject.userId"></el-input>
                    </el-form-item>
                </el-col>

                <el-col :span="24">
                    <el-form-item label="备注">
                        <el-input
                            v-model="formObject.remarks"
                            type="textarea"
                        ></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <!-- <el-row :gutter="20">
                <el-col :span="24">
                    <el-form-item label="备注">
                        <el-input
                            v-model="formObject.remarks"
                            type="textarea"
                        ></el-input>
                    </el-form-item>
                </el-col>
            </el-row> -->
        </el-form>
    </div>
</template>
<script>
import { addEnsureList,editEnsureList } from "@/api/system/tender";
export default {
    data() {
        return {
            formObject: {
                businessType: "3",
                bankId: "",
                changeTime: "",
                createTime: "",
                customerId: "",
                expectBackTime: "",
                payTypeId: "",
                remarks: "",
                tenderId: "",
                type: "",
                userId: "",
            },
        };
    },
    computed:{
        isTask() {
        return this.$store.state.workflow.formType.includes("task") ;
        },
        isEdit() {
        return this.$store.state.workflow.formType === 'edit' ;
        },
    },
    methods: {
        //获取回显数据
        getFormData() {
            
            if (this.$store.state.workflow.businessConfig.formData) {
                this.formObject =
                    this.$store.state.workflow.businessConfig.formData;
            }
        },
        submit() {
            this.formObject.modelId=this.$store.state.workflow.businessConfig.id
            if(this.isEdit){
                editEnsureList(this.formObject).then((res) => {
                if (res.code === 200) {
                    this.$message({
                        message: "修改成功！",
                        type: "success",
                    });
                    this.$store.commit("workflow/SET_BUSINESSDRAWER", false);
                    }
                });
            }else{
                addEnsureList(this.formObject).then((res) => {
                if (res.code === 200) {
                    this.$message({
                        message: "新增成功！",
                        type: "success",
                    });
                    this.$store.commit("workflow/SET_BUSINESSDRAWER", false);
                    }
                });
            }
            
        },
    },
    created() {
        this.getFormData();
    },
};
</script>
<style lang="scss" scoped>
.divider {
    margin: 0;
}
</style>
